///////////////////////////////////////////////////////////////////////////
//
// Spring Engine Source File.
// Copyright (C), Dengtao 2011-2021
// ----------------------------------------------------------------------
// File name:   SfMemoryObject.cpp
// Version:     v1.0.0
// Created:     2013/06/13 23:10 by dengtao
// Compilers:   Visual Studio 2008
// Description: 
// ----------------------------------------------------------------------
// History:
//
///////////////////////////////////////////////////////////////////////////

#include "SfMemoryObject.h"
#include "SfMemoryAllocManager.h"

namespace Sunflower
{
//
//Summary:
//	default constructor.
MemoryObject::MemoryObject()
{
}

//
//Summary:
//	virtual destructor.
MemoryObject::~MemoryObject()
{
}

//
//Summary:
//	override operator new
void* MemoryObject::operator new(size_t size, const char* file, 
	int line, const char* func)
{
	return MemoryAllocManager::GetInstancePtr()->Alloc(size, file, line, func);
}

void* MemoryObject::operator new[](size_t size, const char* file, 
	int line, const char* func)
{
	return MemoryAllocManager::GetInstancePtr()->Alloc(size, file, line, func);
}

//
//Summary:
//	override operator delete
void MemoryObject::operator delete(void* p, const char* file,
	int line, const char* func)
{
	SfUnreferencedParam(p);
	SfUnreferencedParam(file);
	SfUnreferencedParam(line);
	SfUnreferencedParam(func);

	SfAssert(false);

	//return MemoryAllocManager::GetInstance().Free(p, file, line, func);
}

//
//Summary:
//	override operator new
void* MemoryObject::operator new(size_t size)
{
	return MemoryAllocManager::GetInstance().Alloc(size);
}

void* MemoryObject::operator new[](size_t size)
{
	return MemoryAllocManager::GetInstance().Alloc(size);
}

//
//Summary:
//	override operator delete
void MemoryObject::operator delete(void* p)
{
	MemoryAllocManager::GetInstance().Free(p);
}

void MemoryObject::operator delete[](void* p)
{
	MemoryAllocManager::GetInstance().Free(p);
}

}